Skip to content

feat(metrics): add composable metric views support - #9020

Open
rooks-ns wants to merge 3 commits into
open-telemetry:mainfrom
rooks-ns:feat/composable-metric-views
Open

rooks-ns wants to merge 3 commits into
open-telemetry:mainfrom
rooks-ns:feat/composable-metric-views

Conversation

@rooks-ns

@rooks-ns rooks-ns commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Implement experimental composable view matching mode according to the OpenTelemetry Metrics SDK specification and declarative config schema.

  • Introduce ViewMatchingMode (INDEPENDENT, COMPOSABLE).
  • Track explicit View properties in ViewBuilder, View, and RegisteredView to distinguish configured fields from defaults.
  • Implement composable view resolution in ViewRegistry: stream grouping by configured name, last-wins attribute/cardinality merging, backward-scanning aggregation compatibility fallback, and attribute filter conjunction.
  • Add reflection bridge in SdkMeterProviderUtil to safely configure ViewMatchingMode on SdkMeterProviderBuilder without modifying public 1.x APIs.
  • Wire view_matching_mode/development in MeterProviderFactory for declarative configuration.
  • Add comprehensive unit and integration tests.

Fixes #9013

@otelbot otelbot Bot added the api-change Changes to public API surface area label Nov 8, 2026
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-12-05 07:10 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with the author? Comment /dashboard route:author to route it back.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.57%. Comparing base (ddaf381) to head (a52c280).

Files with missing lines Patch % Lines
...emetry/sdk/metrics/internal/view/ViewRegistry.java 96.81% 2 Missing and 3 partials ⚠️
...try/sdk/metrics/internal/SdkMeterProviderUtil.java 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9020      +/-   ##
============================================
+ Coverage     90.50%   90.57%   +0.07%     
- Complexity    11273    11351      +78     
============================================
  Files          1040     1042       +2     
  Lines         30762    30976     +214     
  Branches       4035     4084      +49     
============================================
+ Hits          27840    28058     +218     
+ Misses         1938     1932       -6     
- Partials        984      986       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rooks-ns
rooks-ns force-pushed the feat/composable-metric-views branch from 5b4722c to 71baf95 Compare November 9, 2026 14:39
@otelbot otelbot Bot removed the api-change Changes to public API surface area label Nov 9, 2026
@dashpole
dashpole self-requested a review November 9, 2026 18:11
@rooks-ns
rooks-ns force-pushed the feat/composable-metric-views branch 2 times, most recently from 845fbfd to 6d78faf Compare November 11, 2026 20:22
@rooks-ns
rooks-ns marked this pull request as ready for review November 12, 2026 02:19
@rooks-ns
rooks-ns requested a review from a team as a code owner November 12, 2026 02:19
@rooks-ns
rooks-ns force-pushed the feat/composable-metric-views branch 4 times, most recently from f6bd08b to 0dbd6d0 Compare November 13, 2026 03:53

@dashpole dashpole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I validated that this properly implements the composable view spec.

@otelbot otelbot Bot added the api-change Changes to public API surface area label Nov 13, 2026
@rooks-ns

rooks-ns commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@dashpole commit includes the changes that have been suggested. Thanks.

@opentelemetry-pr-dashboard

This comment has been minimized.

@dashpole dashpole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. I confirmed this addresses #9013.

}

@Override
public final boolean equals(@Nullable Object o) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it should be possible to avoid the public API change here? Overriding equals and hashCode directly on View triggered the api-change check.

.containsExactlyInAnyOrder(expectedKeys);
}

@Test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: ViewRegistryTest does not yet cover COMPOSABLE mode when no views match, when composing Aggregation.drop() with another view, or when falling back to a custom DefaultAggregationSelector or CardinalityLimitSelector.

Implement experimental composable view matching mode according to the OpenTelemetry Metrics SDK specification and declarative config schema.

- Introduce ViewMatchingMode (INDEPENDENT, COMPOSABLE).
- Track explicit View properties in ViewBuilder, View, and RegisteredView to distinguish configured fields from defaults.
- Implement composable view resolution in ViewRegistry: stream grouping by configured name, last-wins attribute/cardinality merging, backward-scanning aggregation compatibility fallback, and attribute filter conjunction.
- Add reflection bridge in SdkMeterProviderUtil to safely configure ViewMatchingMode on SdkMeterProviderBuilder without modifying public 1.x APIs.
- Wire view_matching_mode/development in MeterProviderFactory for declarative configuration.
- Add comprehensive unit and integration tests.

Fixes open-telemetry#9013
…ompatibility, and test coverage

- Keep CompositeAndPredicate package-private with @nullable equals, Objects.hashCode, and toString

- Enforce single canonical RegisteredView.create factory after rebase with OptIn/enabled support

- Restore apidiffs clean state on opentelemetry-sdk-metrics.txt

- Add requested ViewRegistryTest composable edge-case tests, OptInAdviceTest composable test, ViewTest validation coverage, CompositeAndPredicateTest EqualsVerifier, and MeterProviderFactoryTest independent case
@rooks-ns
rooks-ns force-pushed the feat/composable-metric-views branch from ad6265a to a52c280 Compare December 5, 2026 06:46
@otelbot otelbot Bot removed the api-change Changes to public API surface area label Dec 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add experimental view_matching_mode (composable metric views) support

2 participants